package com.example.ass7.task;

import java.io.IOException;
import java.util.List;

import biuoop.KeyboardSensor;

import com.example.ass7.GameFlow;
import com.example.ass7.HighScoresTable;
import com.example.ass7.animation.AnimationRunner;
import com.example.ass7.level.LevelInformation;

/**
 * @author Meirav Ben Izhak
 */
public class StartGameTask implements Task<Void> {

    private final List<LevelInformation> levels;
    private final KeyboardSensor keyboardSensor;
    private final HighScoresTable highScoresTable;
    private final AnimationRunner animationRunner;

    /**
     * @param keyboardSensor
     *            keyboardSensor
     * @param highScoresTable
     *            highScoresTable
     * @param animationRunner
     *            animationRunner
     * @param levels
     *            levels
     */
    public StartGameTask(
        KeyboardSensor keyboardSensor, HighScoresTable highScoresTable,
        AnimationRunner animationRunner, List<LevelInformation> levels) {

        this.levels = levels;
        this.keyboardSensor = keyboardSensor;
        this.highScoresTable = highScoresTable;
        this.animationRunner = animationRunner;
    }

    @Override
    public Void run() {
        try {
            GameFlow gameFlow = new GameFlow(
                    this.animationRunner, this.keyboardSensor,
                    this.highScoresTable);
            gameFlow.runLevels(this.levels);
        } catch (IOException e) {
            System.out
                    .println(e);
        }
        return null;
    }
}